a11y: Add private GtkContainerAccessible functions to add/remove a child
authorCarlos Garnacho <carlosg@gnome.org>
Mon, 10 Mar 2014 15:12:05 +0000 (16:12 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Mon, 10 Mar 2014 22:01:59 +0000 (23:01 +0100)
This may be useful in container implementations, or for internal children
that trigger no signal emission.

https://bugzilla.gnome.org/show_bug.cgi?id=725864

gtk/a11y/Makefile.am
gtk/a11y/gtkcontaineraccessible.c
gtk/a11y/gtkcontaineraccessibleprivate.h [new file with mode: 0644]

index b32099ef4c0175e47f0e831d2afb6b67f3d7236d..b3c90a563b1411718ca7e4fda02969c8fa49857d 100644 (file)
@@ -115,6 +115,7 @@ gtka11y_private_h_sources =         \
        gtkaccessibilityutil.h          \
        gtkcellaccessibleprivate.h      \
        gtkcolorswatchaccessibleprivate.h \
+       gtkcontaineraccessibleprivate.h \
        gtkiconviewaccessibleprivate.h  \
        gtklabelaccessibleprivate.h     \
        gtkflowboxaccessibleprivate.h   \
index fcc7301cbb39308fdc552247ae5ccea29fd7018e..3db0165b2b22079d964530f0cd95a5ba9c8a15c1 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <gtk/gtk.h>
 #include "gtkcontaineraccessible.h"
+#include "gtkcontaineraccessibleprivate.h"
 
 struct _GtkContainerAccessiblePrivate
 {
@@ -118,11 +119,10 @@ gtk_container_accessible_real_add_gtk (GtkContainer *container,
   atk_child = gtk_widget_get_accessible (widget);
   accessible = GTK_CONTAINER_ACCESSIBLE (atk_parent);
 
-  g_object_notify (G_OBJECT (atk_child), "accessible-parent");
   g_list_free (accessible->priv->children);
   accessible->priv->children = gtk_container_get_children (container);
   index = g_list_index (accessible->priv->children, widget);
-  g_signal_emit_by_name (atk_parent, "children-changed::add", index, atk_child, NULL);
+  _gtk_container_accessible_add_child (accessible, atk_child, index);
 
   return 1;
 }
@@ -143,12 +143,11 @@ gtk_container_accessible_real_remove_gtk (GtkContainer *container,
     return 1;
   accessible = GTK_CONTAINER_ACCESSIBLE (atk_parent);
 
-  g_object_notify (G_OBJECT (atk_child), "accessible-parent");
   index = g_list_index (accessible->priv->children, widget);
   g_list_free (accessible->priv->children);
   accessible->priv->children = gtk_container_get_children (container);
-  if (index >= 0 && index <= g_list_length (accessible->priv->children))
-    g_signal_emit_by_name (atk_parent, "children-changed::remove", index, atk_child, NULL);
+  if (index >= 0)
+    _gtk_container_accessible_remove_child (accessible, atk_child, index);
 
   return 1;
 }
@@ -200,3 +199,21 @@ gtk_container_accessible_init (GtkContainerAccessible *container)
 {
   container->priv = gtk_container_accessible_get_instance_private (container);
 }
+
+void
+_gtk_container_accessible_add_child (GtkContainerAccessible *accessible,
+                                     AtkObject              *child,
+                                     gint                    index)
+{
+  g_object_notify (G_OBJECT (child), "accessible-parent");
+  g_signal_emit_by_name (accessible, "children-changed::add", index, child, NULL);
+}
+
+void
+_gtk_container_accessible_remove_child (GtkContainerAccessible *accessible,
+                                        AtkObject              *child,
+                                        gint                    index)
+{
+  g_object_notify (G_OBJECT (child), "accessible-parent");
+  g_signal_emit_by_name (accessible, "children-changed::remove", index, child, NULL);
+}
diff --git a/gtk/a11y/gtkcontaineraccessibleprivate.h b/gtk/a11y/gtkcontaineraccessibleprivate.h
new file mode 100644 (file)
index 0000000..fa692ce
--- /dev/null
@@ -0,0 +1,33 @@
+/* GTK+ - accessibility implementations
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTK_CONTAINER_ACCESSIBLE_PRIVATE_H__
+#define __GTK_CONTAINER_ACCESSIBLE_PRIVATE_H__
+
+#include <gtk/a11y/gtkcontaineraccessible.h>
+
+G_BEGIN_DECLS
+
+void _gtk_container_accessible_add_child    (GtkContainerAccessible *accessible,
+                                             AtkObject              *child,
+                                             gint                    index);
+void _gtk_container_accessible_remove_child (GtkContainerAccessible *accessible,
+                                             AtkObject              *child,
+                                             gint                    index);
+G_END_DECLS
+
+#endif /* __GTK_CONTAINER_ACCESSIBLE_PRIVATE_H__ */